package com.ly.web.controller.erp;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.KingTravelTripEntity;
import com.ly.heart.service.IKingTravelTripService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 差旅费报销单的行程单Controller
 * 
 * @author wutao
 * @date 2024-08-23
 */
@Api(value = "trip", tags = "差旅费报销单的行程单")
@RestController
@RequestMapping("/heart/trip")
public class KingTravelTripController extends BaseController {

    @Resource
    private IKingTravelTripService kingTravelTripEntityService;

    /**
     * 查询差旅费报销单的行程单列表
     */
    @PreAuthorize("@ss.hasPermi('heart:trip:list')")
    @GetMapping("/list")
    @ApiOperation("查询差旅费报销单的行程单列表")
    public TableDataInfo list(KingTravelTripEntity kingTravelTripEntity)
    {
        startPage();
        List<KingTravelTripEntity> list = kingTravelTripEntityService.selectKingTravelTripEntityList(kingTravelTripEntity);
        return getDataTable(list);
    }

    /**
     * 导出差旅费报销单的行程单列表
     */
    @PreAuthorize("@ss.hasPermi('heart:trip:export')")
    @Log(title = "差旅费报销单的行程单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出差旅费报销单的行程单列表")
    public AjaxResult export(KingTravelTripEntity kingTravelTripEntity)
    {
        List<KingTravelTripEntity> list = kingTravelTripEntityService.selectKingTravelTripEntityList(kingTravelTripEntity);
        ExcelUtil<KingTravelTripEntity> util = new ExcelUtil<KingTravelTripEntity>(KingTravelTripEntity.class);
        return util.exportExcel(list, "trip");
    }

    /**
     * 获取差旅费报销单的行程单详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:trip:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取差旅费报销单的行程单详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(kingTravelTripEntityService.selectKingTravelTripEntityById(id));
    }

    /**
     * 新增差旅费报销单的行程单
     */
    @PreAuthorize("@ss.hasPermi('heart:trip:add')")
    @Log(title = "差旅费报销单的行程单", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增差旅费报销单的行程单")
    public AjaxResult add(@RequestBody KingTravelTripEntity kingTravelTripEntity)
    {
        return toAjax(kingTravelTripEntityService.insertKingTravelTripEntity(kingTravelTripEntity));
    }

    /**
     * 修改差旅费报销单的行程单
     */
    @PreAuthorize("@ss.hasPermi('heart:trip:edit')")
    @Log(title = "差旅费报销单的行程单", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改差旅费报销单的行程单")
    public AjaxResult edit(@RequestBody KingTravelTripEntity kingTravelTripEntity)
    {
        return toAjax(kingTravelTripEntityService.updateKingTravelTripEntity(kingTravelTripEntity));
    }

    /**
     * 删除差旅费报销单的行程单
     */
    @PreAuthorize("@ss.hasPermi('heart:trip:remove')")
    @Log(title = "差旅费报销单的行程单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除差旅费报销单的行程单")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(kingTravelTripEntityService.deleteKingTravelTripEntityByIds(ids));
    }
}
